package com.weilele.base.library

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.viewbinding.ViewBinding
import com.weilele.mvvm.base.MvvmKeyboardDialog
import com.weilele.mvvm.base.helper.LiveDataWrap
import com.weilele.mvvm.base.helper.appCompatActivity
import com.weilele.mvvm.utils.activity.dip


abstract class BaseImeDialog<Binding : ViewBinding?> : MvvmKeyboardDialog(), IBaseHelper,
    IBaseHelperView<Binding> by BaseHelperImpl() {

    final override fun getLayoutResOrView(inflater: LayoutInflater, parent: ViewGroup?): Any? {
        val activity = appCompatActivity
        return if (activity == null) {
            null
        } else {
            getContentView(
                this,
                onCreateContentView(inflater, parent),
                activity,
                inflater,
                parent,
                isNeedToolbar(),
                isReplaceActionBar(),
                isNeedBackIcon(),
                isNeedSwitchView()
            )
        }
    }

    override fun getObserverLiveData(): List<LiveDataWrap>? {
        return super.getObserverLiveData()
    }

    override fun initUi(savedInstanceState: Bundle?) {
    }

    override fun initData() {
    }


    override fun getClickView(): List<View?>? = null


    override fun onSingleClick(view: View) {

    }

    override fun onRootViewLayoutParams(lp: FrameLayout.LayoutParams) {
        super.onRootViewLayoutParams(lp)
        lp.marginStart = dip(24)
        lp.marginEnd = dip(24)
    }
}